/**
 * ProjectEntityHandlerBean.java
 * 
 */

package com.example.managedbeans;



import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;


import com.example.entities.*;
import com.example.service.*;





public class ProjectEntityHandlerBean
{
  private String projectName;
  private String description;
  private String duration;
  private  List<Project> projectList;


public ProjectEntityHandlerBean()
{
	
}
    
  


	

	public String getProjectName() {
	return projectName;
}

public void setProjectName(final String projectName) {
	this.projectName = projectName;
}

	public String getDescription() {
	return description;
}

public void setDescription(final String description) {
	this.description = description;
}

public String getDuration() {
	return duration;
}

public void setDuration(final String duration) {
	this.duration = duration;
}

public List<Project> getProjectList() {  
    return projectList;  
} 



	public String insertNewProject()
    {   
		System.out.println("Enter insert method");
    	Project project = new Project();
    	project.setProjectName(this.projectName);
    	project.setDescription(this.description);
    	project.setDuration(this.duration);
    	ProjectHandler ph = new ProjectHandler();
    	ph.create(project);
    	return "viewid?faces-redirect=true";


    }
	
	public String getAllProjects()
	{
		ProjectHandler ph = new ProjectHandler();
		projectList = ph.getAllProjects();
		return "true";		
	}
	
	public String delete()
	{
		ProjectHandler ph = new ProjectHandler();
		ph.deleteByProjectName(this.projectName);
		return "true";
	}
	public String test()
	{
		System.out.println("Test");
		return "failure";
	}
    
 
}
